<template>
  <view class="login-container">
    <view class="logo">
      <text class="logo-text">问道青城</text>
    </view>
    <view class="input-group">
      <text class="label">手机号码</text>
      <view class="input-container">
        <input type="text" placeholder="请输入手机号" v-model="phone">
      </view>
    </view>

    <view class="input-group">
      <text class="label">验证码</text>
      <view class="code-input-container">
        <input type="text" placeholder="请输入验证码" v-model="code" class="code-input">
        <button class="code-button" @click="getCode">
          获取验证码
        </button>
      </view>
    </view>
    <button class="login-button" @click="login">立即登录</button>
  </view>
</template>

<script>
export default {
  data() {
    return {
      phone: '',
      code: ''
    };
  },
  methods: {
    getCode() {
      // 显示固定验证码弹窗
      uni.showModal({
        title: '您的验证码',
        content: '5244',
        showCancel: false,
        confirmColor: '#1a955f'
      });
    },
    login() {
      // 简单验证逻辑
      if (!this.phone) {
        uni.showToast({
          title: '请输入手机号',
          icon: 'none'
        });
        return;
      }

      if (this.code !== '5244') {
        uni.showToast({
          title: '验证码错误',
          icon: 'none'
        });
        return;
      }

      // 跳转到首页
      uni.reLaunch({
        url: '/pages/start/start'
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: radial-gradient(circle, #1a955f, #ffffff);
  /* 从中间向外的渐变背景 */
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 50px;
}

.logo-text {
  font-size: 24px;
  font-weight: bold;
  color: #1a955f;
}

.input-group {
  width: 80%;
  margin-bottom: 20px;
}

.code-input-container {
  display: flex;
  align-items: center;
  position: relative;
  border-bottom: 1px solid #1a955f;
  /* 保持下划线样式 */
}

.code-input {
  flex: 1;
  padding: 10px 0;
  border: none;
  /* 移除默认边框 */
  font-size: 16px;
}

.code-button {
  background: #1a955f !important;
  color: white !important;
  border-radius: 20px;
  padding: 6px 15px;
  font-size: 12px;
  margin-left: 10px;
  white-space: nowrap;
  /* 移除绝对定位 */
}

.label {
  margin-bottom: 5px;
  font-size: 16px;
  color: #1a955f;
}

.input-group {
  width: 80%;
  margin-bottom: 20px;

  // 新增下划线容器
  .input-container {
    border-bottom: 1px solid #1a955f;
  }
}

// 手机号输入框特殊处理
input:not(.code-input) {
  padding: 10px 0;
  border: none;
  width: 100%;

  // placeholder左对齐
  &::placeholder {
    text-align: left;
  }
}

.login-button {
  width: 80%;
  padding: 12px;
  border-radius: 50px;
  font-size: 16px;
  font-weight: bold;
  background-color: #1a955f;
  color: #fff;
  margin-top: 20px;
}

.agreement {
  margin-top: 20px;
  font-size: 14px;
  color: #1a955f;
}

.link {
  color: red;
  cursor: pointer;
}
</style>
